<?php 

namespace app\home\controller;
use app\home\controller\Common;
use think\Request;
use think\Db;
/**
 * @title 首页
 * @group 樱桃荟
 */
class Index extends Common
{
	/**
     * @title 首页
     * @url /home/Index/index
     * @author  雪飞鸟
     * @method GET
     * @return notice:公告内容
     * @return number:在线人数
     * @return money:资金池
     */
	public function index(Request $request)
	{
		$notice = Db::name('notice')->order('id','desc')->find();
		$config = Db::name('config')->order('id','desc')->find();
		if ($notice) 
		{
			return json_success(['notice' => $notice['content'], 'number' => $config['edit_online_num'], 'money' => $config['jackpot']]);
		}
		else
		{
			return json_error('暂无公告');
		}
	}

	

	/**
     *  @title 房间列表
     *  @url /home/Index/roomList
     *  @method POST
     *  @param name:roomT type:int require:1 other: desc:房间类型
     *  @return room_list:房间列表@
     *  @room_list room_name:房间名称 gold_range:金币范围 odds:倍数
     *  @author  雪飞鸟
     */
	public function roomList(Request $request)
	{
		$rType 	= $request->param('roomT');
		$rlist 	= Db::name('room')->where(['type' => $rType, 'room_switch' => 1])->select();
		if ($rlist) 
		{
			return json_success(['roomList' => $rlist]);
		}
		else
		{
			return json_error('房间类型错误');
		}
	}
}




